/* rcctwbc4.p  -  CONTAINER WORKBENCH - SUB PROGRAM ADD WEIGHT, VOLUME UP     */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.5.1.2 $                                                         */
/*V8:ConvertMode=NoConvert                                                    */
/* VERSION 7.5      LAST MODIFIED: 07/11/95           BY: GWM *J049*          */
/* VERSION 8.6      LAST MODIFIED: 10/02/96           BY: kxn *K003*          */
/* VERSION 8.6      LAST MODIFIED: 05/20/98           BY: *K1Q4* Alfred Tan   */
/* VERSION 9.1      LAST MODIFIED: 08/12/00           BY: *N0KP* Mark Brown   */
/* $Revision: 1.5.1.2 $    BY: Jean Miller    DATE: 03/22/01 ECO: *P008*        */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}

/* INPUT PARAMETERS */
define input parameter abs_recid as recid.
define input parameter wght like abs_nwt.
define input parameter wght_um like abs_wt_um.

/* LOCAL VARIABLES */
define variable conv_rate as decimal no-undo.
define variable kit_item as logical no-undo.

/* BUFFERS */
define buffer abs_temp for abs_mstr.

/* INITIALIZE THE BUFFERS */

find abs_mstr where abs_recid = recid(abs_mstr) no-lock.

kit_item = if abs_id begins "I" then
              yes
           else
              no.

/* HANDLE PARENT RECORDS */
find abs_temp where
     abs_temp.abs_shipfrom = abs_mstr.abs_shipfrom and
     abs_temp.abs_id = abs_mstr.abs_par_id
exclusive-lock no-error.

if available abs_temp and
             abs_temp.abs_wt_um = ""
then
   abs_temp.abs_wt_um = wght_um.

/* LOOP THROUGH THE CHILD & PARENT RECORDS ADDING THE WEIGHT       */
/* UP THE CHAIN                                                    */
repeat while available abs_temp:

   conv_rate = 1.

   if wght_um <> abs_temp.abs_wt_um then do:

      {gprun.i ""gpumcnv.p""
         "(input wght_um,
           input abs_temp.abs_wt_um,
           input '',
           output conv_rate)"}

      if conv_rate = ? then conv_rate = 1.

   end.

   assign
      abs_temp.abs_gwt = abs_temp.abs_gwt + (wght * conv_rate).

   if kit_item then leave.

   find abs_mstr where recid(abs_mstr) = recid(abs_temp)
   no-lock.

   find abs_temp where
        abs_temp.abs_shipfrom = abs_mstr.abs_shipfrom and
        abs_temp.abs_id = abs_mstr.abs_par_id
   exclusive-lock no-error.

end.
